﻿// -----------------------------------------------------------------------
// <copyright file="ReceiveCompleteEventArgs.cs" company="TaskyMedia LLC">
// Copyright (c) TaskyMedia LLC
// </copyright>
// -----------------------------------------------------------------------

namespace SohpClient
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// Contains the data received from the completion of the <c>ReceiveAsync</c> method.
    /// </summary>
    public class ReceiveCompleteEventArgs : AsyncCompleteEventArgs
    {
        /// <summary>
        /// The data received from the server.
        /// </summary>
        private byte[] data;

        /// <summary>
        /// Initializes a new instance of the <see cref="ReceiveCompleteEventArgs"/> class.
        /// </summary>
        /// <param name="data">The data received from the server.</param>
        /// <param name="asyncState">The asynchronous state object.</param>
        /// <param name="isSuccess">If set to <c>true</c> the operation was successful.</param>
        public ReceiveCompleteEventArgs(byte[] data, object asyncState, bool isSuccess)
            : base(asyncState, isSuccess)
        {
            this.data = data;
        }

        /// <summary>
        /// Gets a value indicating whether this instance has data.
        /// </summary>
        /// <value>
        ///   <c>true</c> if this instance has data; otherwise, <c>false</c>.
        /// </value>
        public bool HasData
        {
            get
            {
                return this.data != null;
            }
        }

        /// <summary>
        /// Gets the data received from the server.
        /// </summary>
        /// <returns>Returns a <c>byte</c> array of data received from the server.</returns>
        public byte[] GetData()
        {
            return this.data;
        }
    }
}
